#include "Sphere.h"

namespace shapes{

Sphere::Sphere()
: quadric(0), radius(1.0f) 
{
	slices = 32;
	stacks = 32;
}

Sphere::Sphere(Sphere& sphere) 
  : radius(sphere.radius), quadric(0)
{
	slices = sphere.slices;
	stacks = sphere.stacks;
}


Sphere::~Sphere() {
  if ( quadric != 0 ) {
    gluDeleteQuadric( quadric );
  }
}

Sphere& Sphere::operator=(Sphere& sphere) 
{
  slices = sphere.slices;
  stacks = sphere.stacks; 
  radius = sphere.radius;
  // no need to change d_quadric
  return *this;
}

void Sphere::draw() {
  ShapeNode::draw();
  if ( quadric == 0 ) {
    quadric = gluNewQuadric();
    gluQuadricDrawStyle( quadric, GLU_FILL );
    gluQuadricNormals( quadric, GLU_FLAT );
  }
  glColor3f( r, g, b);
  gluSphere( quadric, radius, slices, stacks );
  ShapeNode::drawFinish();
}
}